
package com.punch.common.feign.fallback;


import com.punch.common.dto.login.WXUserDTO;
import com.punch.common.feign.FeignGuardianService;
import com.punch.common.model.LoginUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;


/**
 * userService降级工场
 *
 * @author zlt
 * @date 2019/1/18
 */

@Slf4j
@Component
public class FeignGuardianServiceFallbackFactory implements FallbackFactory<FeignGuardianService> {
    @Override
    public FeignGuardianService create(Throwable throwable) {
        return new FeignGuardianService() {

            /**
             * 根据openId获取小程序登录信息
             *
             * @param openId 小程序openId
             */
            @Override
            public LoginUser getFeignGuardianByOpenId(String openId) {
                log.error("根据openId获取小程序登录信息异常:{}", openId, throwable);
                return new LoginUser();
            }

            /**
             * 进行注册
             *
             * wxUserDTO 微信用户信息
             */
            @Override
            public void saveFeignGuardian(@RequestBody WXUserDTO wxUserDTO) {
                log.error("根据openId与手机号码获取小程序登录信息异常:{}", wxUserDTO, throwable);

            }
        };
    }
}

